import React from 'react'
import ReactDom from 'react-dom'
import {Provider} from 'react-redux';
import configureStore from './configureStore';
// how to use react-hot-loader https://github.com/gaearon/react-hot-loader/issues/243
import {AppContainer} from 'react-hot-loader'
import App from './app.js';
import './index.less'

import moment from 'moment'
import 'moment/locale/zh-cn';

moment.locale('zh_cn');

const store = configureStore();

renderWithHotReload(App);

if (module.hot) {
    module.hot.accept('./app', () => {
        const NextApp = require('./app').default;
        renderWithHotReload(NextApp);
    });
}

function renderWithHotReload(RootElement) {
    ReactDom.render(
        <AppContainer>
            <Provider store={store}>
                <RootElement/>
            </Provider>
        </AppContainer>,
        document.getElementById('root')
    )
}
